<?php namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Devices extends Model {

	//
	protected $table = 'devices';
	protected $fillable = ['name', 'uid', 'model', 'theory', 'creator', 'minimize_price', 'maximize_price', 'auth_info', 'standard', 'image', 'description', 'efficiency', 'verify_state'];

	public function user()
	{
		return $this->hasOne("App\Models\Users", "id", "uid");
	}

	public function deviceDomain()
	{
		return $this->hasOne("App\Models\DeviceDomain", "device_id", "id");
	}

	public function deviceCompliant()
	{
		return $this->hasMany("App\Models\DeviceCompliant", "device_id", "id");
	}


	public function deviceAward()
	{
		return $this->hasMany("App\Models\DeviceAward", "device_id", "id");
	}

	public function deviceContact()
	{
		return $this->hasOne("App\Models\DeviceContact", "device_id", "id");
	}

	public function deviceFunctions()
	{
		return $this->hasMany("App\Models\DeviceFunctions", "device_id", "id");
	}

	public function deviceImages()
	{
		return $this->hasMany("App\Models\DeviceImages", "device_id", "id");
	}

	public function deviceFeatures()
	{
		return $this->hasMany("App\Models\DeviceFeatures", "device_id", "id");
	}

	public function deviceCases()
	{
		return $this->hasMany("App\Models\DeviceCases", "device_id", "id");
	}

	public function deviceTech()
	{
		return $this->hasOne("App\Models\DeviceTech", "device_id", "id");
	}

	public function deviceProject()
	{
		return $this->hasMany("App\Models\ProjectDevice", "device_id", "id");
	}

	public function mainbody()
	{
		return $this->hasMany("App\Models\DeviceMainBody", "device_id", 'id');
	}

	public function finance()
	{
		return $this->hasOne("App\Models\Financing", "related_id", "id")->where("type", env("FINANCING_DEVICE"));
	}

}
